#ifndef TUIODEMO_H_INCLUDED
#define TUIODEMO_H_INCLUDED

#include "TuioListener.h"
#include "TuioClient.h"
#include "Graphic.hxx"
#include "imageloader.h"
#include <SDL/SDL_mixer.h>

#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif

#ifdef __APPLE__
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif

class TuioDemo : public TuioListener, public Graphic
{
    public:
        TuioDemo(TuioClient * client);

		void multMatrix(double a[16], double b[16]);
   		void computeMatrix();   
		void detectaPais();
		void addTuioObject(TuioObject *tobj);
		void updateTuioObject(TuioObject *tobj);
		void removeTuioObject(TuioObject *tobj);
		void addTuioCursor(TuioCursor *tcur);
		void computePosition(TuioCursor *tcur);
		void updateTuioCursor(TuioCursor *tcur);
		void removeTuioCursor(TuioCursor *tcur);
		void refresh(long timestamp);
		void drawMapaMundi();
		void drawTextInfo(float x, float y, double m[16], int ditpos);
		virtual void Init();
		GLuint loadTexture(Image* image);
        virtual void Idle(){}
        virtual void Draw(){drawObjects();}
        virtual void End(){}
        virtual void ExecuteKey(int key){}

    private:
		void drawObjects();
        void drawString(char* str);
        char buff[200];
        TuioClient *tuioClient;
		GLint mapaID; // Per guardar textura del mapa
		float map_x, map_y, map_a, map_z; // Per guardar posició del mapa
		int dit1_id, dit2_id, dit1_s, dit2_s;
		float dit1_x, dit2_x, dit1_y, dit2_y;
		float incxf,incyf,incaf,inczf;
		double modelview[16];
		double alt_modelview[16];
		float xi,yi,xii,yii;
		float tp1x,tp1y,tp2x,tp2y;
	
		//Audio constants
		int volume;
		Mix_Chunk *sampleNA;
		Mix_Chunk *sampleSA;
		Mix_Chunk *sampleAF;
		Mix_Chunk *sampleEU;
	

};

#endif // TUIODEMO_H_INCLUDED
